{% extends "base.html" %}
{% load humanize %}
{% load static %}
{% get_static_prefix as STATIC_PREFIX %}

{% block header %}
	{{ block.super }}
	<h2>{{ ticket.title }} &ndash; {{ ticket.submitter_email }}</h2>
{% endblock %}

{% block body %}
	<div id='ticket-section'>
		{% if ticket.status == 4 or ticket.status == 3 %}
			<div class='re-open-box' title='If you need the ticket to be revisited or are unhappy with the results, Re-Open the ticket by clicking here'>
				<a href='{% url public_ticket_re_open ticket_id=ticket.id %}'>Re-Open Ticket</a>
			</div>
		{% endif %}
		<div class='ticket-dates-status'>
			<h1>Status</h1> 
			{{ ticket.get_status_display }}
			<hr>
			<h1>Priority</h1> 
			{{ ticket.get_priority_display }}
			<hr>
			<h1>Dates</h1>
			 <span title='{{ ticket.created }}'>Created: {{ ticket.created|naturalday }}</span><br />
			<span title='{{ ticket.modified }}'>Modified: {{ ticket.modified|naturalday }}</span>
		</div>
		{{ ticket.description|urlize|linebreaks }}
	</div>

	<h1>Notes</h1>
	<div id='notes-section'>

		{% if ticket.note_set.all %}
			{% for note in ticket.note_set.all %}
				<div class='notes-row {% cycle 'odd' 'even' %}' >
					<img class='notes-img' src='{{ STATIC_PREFIX }}img/action/{{ note.action }}.png' title='{{ note.get_action_display }}'>
					<span class='notes-date' title='{{ note.date }}'>{{ note.date|naturalday }}</span>
					<span class='notes-email'>{{ note.submitter_email }}</span><br />
					<span class='notes-comment'>{{ note.comment|urlize|linebreaks }}</span>
				</div>
			{% endfor %}
		{% else %}
			No Notes Entered
		{% endif %}

	</div>

	{% if form %}
		<div class='form-box'>
			<div class='form-title'>Add Note</div>
			<form method="POST" action="{% url public_add_note ticket_id=ticket.id %}">
				{% csrf_token %}
				{{ form.as_p }}
				<input type="submit" value="Create Note" />
			</form>
		</div>
	{% endif %}
{% endblock %}
